<?php
/*
 * Created on Feb 24, 2008
* @author max
*/
include_once(dirname(__FILE__).'/../database/dbShifts.php');
include_once(dirname(__FILE__).'/../database/dbDates.php');
class testdbShifts extends UnitTestCase {
	function testdbShiftsModule() {
		$s1=new Shift("02-25-08-night",3, null, "", "");
		$this->assertTrue(insert_dbShifts($s1));
		$this->assertTrue(delete_dbShifts($s1));
		$s2=new Shift("02-25-08-15-18",3, null, "", "");
		$this->assertTrue(insert_dbShifts($s2));
		$this->assertTrue(select_dbShifts("02-25-08-15-18")!==null);
		$s2=new Shift("02-25-08-15-18",2, null, "", "");
		$this->assertTrue(update_dbShifts($s2));
		$shifts[] = $s2;
		$this->assertTrue(get_shift_name_from_id($s2->get_id())=="Monday, February 25th, 2008 from 3pm to 6pm");
		// test moving a shift around
		$s3 = new Shift("02-25-08-12-15",2, null, "", "");
		$shifts[] = $s3;
		$this->assertTrue(insert_dbShifts($s3));
		$d = new RMHdate("02-25-08",$shifts,"","");
		$this->assertTrue(insert_dbDates($d));
		$this->assertTrue(move_shift($s3, 9, 12));
		$this->assertTrue($s3->get_start_time()==9);
		$this->assertTrue(get_shift_name_from_id($s3->get_id())=="Monday, February 25th, 2008 from 9am to 12pm");
		$this->assertFalse(move_shift($s3, 12, 16));
		$s3->set_start_end_time(9, 12);
		$this->assertTrue(delete_dbShifts($s3));

		$this->assertTrue(delete_dbShifts($s2));
		$this->assertTrue(delete_dbDates($d));
    // new entries
		$s4=new Shift("03-21-09-3-6",2, null, "", "");
		$this->assertTrue(update_dbShifts($s4));
		$this->assertTrue(delete_dbShifts($s4));
		$this->assertTrue(get_shift_month($s4->get_id()) == "03");
		$this->assertTrue(get_shift_day($s4->get_id()) == "21");
		$this->assertTrue(get_shift_year($s4->get_id()) == "09");
		echo ("testdbShifts complete");
	}
}
?>
